<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "user_fund".
 *
 * @property int $id 资金ID
 * @property int $userid 用户ID
 * @property string $user_sum 余额
 * @property int $addtime 添加时间
 */
class UserFund extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_fund';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['userid', 'addtime'], 'required'],
            [['userid', 'addtime'], 'integer'],
            [['user_sum'], 'number'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '资金ID',
            'userid' => '用户ID',
            'user_sum' => '余额',
            'addtime' => '添加时间',
        ];
    }
    
    
    public static function getUserFundArrayByUserid($userid){
        $sql = "select * from user_fund where userid=$userid";
        $command = \Yii::$app->db->createCommand($sql);
        return $command->queryOne();
    }
}
